package dragon

import (
	"http"

	appengineSessions "gorilla.googlecode.com/hg/gorilla/appengine/sessions"
	"gorilla.googlecode.com/hg/gorilla/sessions"
)

const user = "115396442595599374875"
const ytuser = "7dhdragon"
const method = "json"
const apiver = "2"
const thumbsize = "180u"
const imgmax = "800u"

const albumspageURL = "/albumy/strona/"
const moviesURL = "/filmy"
const documentsURL = "/dokumenty"
const campsURL = "/obozy"
const aboutusURL = "/onas"
const historyURL = "/historia"
const matchURL = "/zapalka"
const photosURL = "/zdjecia/"
const newspageURL = "/wiesci/strona/"
const guestbookpageURL = "/ksiega/strona/"
const guestbookaddURL = "/ksiega/wpis"
const articleURL = "/artykul/"
const eventsURL = "/imprezy"
const heroURL = "/bohater"
const squadURL = "/sklad"
const constURL = "/konstytucja"
const linksURL = "/linki"
const calendarURL = "/kalendarz"

const admaboutusURL = "/admin/onas"
const admhistoryURL = "/admin/historia"
const admheroURL = "/admin/bohater"
const admsquadURL = "/admin/sklad"
const admconstURL = "/admin/konstytucja"
const admlinksURL = "/admin/linki"
const admguestbookURL = "/admin/ksiega"
const admguestbookeditURL = "/admin/ksiega/edytuj/"
const admguestbookdelURL = "/admin/ksiega/usun/"
const admarticleaddURL = "/admin/artykul/dodaj/"
const admarticleeditURL = "/admin/artykul/edytuj/"
const admarticledelURL = "/admin/artykul/usun/"
const adminURL = "/admin"
const admarticlesURL = "/admin/artykuly"

type feed struct {
        Entry []map[string]interface{} "entry"
}

type data struct {
        Feed    feed   "feed"
}

type counters struct {
	Kind	string
	Count	int
}

func init() {
	sessions.SetStore("memcache", new(appengineSessions.MemcacheSessionStore))
	sessions.SetStoreKeys("memcache", []byte("123456"))

	http.HandleFunc(albumspageURL, handleAlbums)
	http.HandleFunc(photosURL, handlePhotos)
	http.HandleFunc(guestbookpageURL, handleGuestbook)
	http.HandleFunc(guestbookaddURL, handleGuestbookAdd)
	http.HandleFunc(campsURL, handleArticles)
	http.HandleFunc(historyURL, handlePage)
	http.HandleFunc(matchURL, handleArticles)
	http.HandleFunc(articleURL, handleArticleShow)
	http.HandleFunc(moviesURL, handleMovies)
	http.HandleFunc(documentsURL, handleDocuments)
	http.HandleFunc(newspageURL, handleArticles)
	http.HandleFunc(eventsURL, handleArticles)
	http.HandleFunc(heroURL, handlePage)
	http.HandleFunc(squadURL, handlePage)
	http.HandleFunc(constURL, handlePage)
	http.HandleFunc(linksURL, handlePage)
	http.HandleFunc(aboutusURL, handlePage)
	http.HandleFunc(calendarURL, handleCalendar)

	http.HandleFunc(admaboutusURL, handleAdminPage)
	http.HandleFunc(admheroURL, handleAdminPage)
	http.HandleFunc(admhistoryURL, handleAdminPage)
	http.HandleFunc(admsquadURL, handleAdminPage)
	http.HandleFunc(admconstURL, handleAdminPage)
	http.HandleFunc(admlinksURL, handleAdminPage)
	http.HandleFunc(admguestbookURL, handleAdminGuestbook)
	http.HandleFunc(admguestbookeditURL, handleGuestbookEdit)
	http.HandleFunc(admguestbookdelURL, handleGuestbookDelete)
	http.HandleFunc(admarticleaddURL, handleArticleAdd)
	http.HandleFunc(admarticleeditURL, handleArticleEdit)
	http.HandleFunc(admarticledelURL, handleArticleDelete)
	http.HandleFunc(adminURL, handleAdmin)
	http.HandleFunc(admarticlesURL, handleAdminArticles)
	http.HandleFunc("/", handleRoot)
}
